package com.vine.account.service.impl;

import cn.hutool.core.util.StrUtil;
import com.vine.account.entity.XAccount;
import com.vine.account.mapper.XAccountMapper;
import com.vine.account.service.XAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import java.util.List;

@Service
public class XAccountServiceImpl implements XAccountService {

    @Autowired
    private XAccountMapper xAccountMapper;

    @Override
    public List<XAccount> getAll() {
        // 查询所有
        return xAccountMapper.selectAll();
    }

    @Override
    public List<XAccount> getByAccount(String account) {
        if (StrUtil.isBlank(account)) {
            return getAll();
        }
        // 使用Example构建查询条件
        Example example = new Example(XAccount.class);
        example.createCriteria().andEqualTo("account", account);
        return xAccountMapper.selectByExample(example);
    }
}
